package cs340.stormtroopers.junitTests.phase4WhiteBox;

import junit.framework.TestCase;
import cs340.stormtroopers.hypeerweb.HyPeerWeb;
import cs340.stormtroopers.hypeerweb.Node;

/**
 * White box tests on the Node class.
 * Does relational value testing.
 * @author Andy Morrow
 *
 */
public class NodeWhiteBoxTest extends TestCase
{
	/**
	 * This method is designed to do relational value testing.
	 * It is specifically trying to test the findDeletionPoint() method
	 * and the followBiggestNeighbor() method, which it calls.
	 */
	public void testRelationalValues()
	{
		HyPeerWeb hw = HyPeerWeb.getSingleton();
		hw.clear();
		for (int i = 0; i < 128; i++)
			hw.addToHyPeerWeb(new Node(0), null);
		
		// first - fold of the end cap node is 0
		Node deletionPoint = hw.getNode(126).findDeletionPoint();
		assertTrue(deletionPoint.getWebIdValue() == 127);
		
		// next - fold of the end cap node is not 0
		hw.addToHyPeerWeb(new Node(0), null);
		deletionPoint = hw.getNode(126).findDeletionPoint();
		assertTrue(deletionPoint.getWebIdValue() == 128);
		
		// next - only one node in the hypeerweb
		hw.clear();
		hw.addToHyPeerWeb(new Node(0), null);
		deletionPoint = hw.getNode(0).findDeletionPoint();
		assertTrue(deletionPoint.getWebIdValue() == 0);
	}
}
